package com.lyj.threads;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 自定义生产线程的线程池工厂
 */
public class MySelfThreadFactory implements ThreadFactory {

    private AtomicInteger count = new AtomicInteger(0);
    @Override
    public Thread newThread(Runnable r) {
        Thread t = new Thread(r);
        String threadName = CustomerThreadPoolExecutor.class.getSimpleName()  +  count.addAndGet(1);
        t.setName(threadName);
        return t;
    }
}
